## Hamel and Bauer, PAG
## Observational analyses

## Loading packages
library(tidyverse)
library(stargazer)

## Loading data
load("obs_data.RData")
load("ces.RData")
load("earmarks2022.RData")


## Table 1 and Table A1
summary(edu<-lm(incvote ~ edu_awards_amount*factor(gender) + abs(nokken_poole_dim1) +
             po1 + spendgap + fr + in_party + midterm + approve + 
             + rdi + incpres + incvotep + memberinhouseparty + cmte_approp + cmte_ways + chair + rankingminority 
             + partyleader + factor(year), data = obs_data %>% filter(capital == 0)))

summary(hhs<-lm(incvote ~ hhs_awards_amount*factor(gender) + abs(nokken_poole_dim1) +
                  po1 + spendgap + fr + in_party + midterm + approve + 
                  + rdi + incpres + incvotep + memberinhouseparty + cmte_approp + cmte_ways + chair + rankingminority 
                + partyleader + factor(year), data = obs_data %>% filter(capital == 0)))

summary(ag<-lm(incvote ~ ag_awards_amount*factor(gender) + abs(nokken_poole_dim1) +
                  po1 + spendgap + fr + in_party + midterm + approve + 
                  + rdi + incpres + incvotep + memberinhouseparty + cmte_approp + cmte_ways + chair + rankingminority 
               + partyleader + factor(year), data = obs_data %>% filter(capital == 0)))

summary(transportation<-lm(incvote ~ transp_awards_amount*factor(gender) + abs(nokken_poole_dim1) +
                  po1 + spendgap + fr + in_party + midterm + approve + 
                  + rdi + incpres + incvotep + memberinhouseparty + cmte_approp + cmte_ways + chair + rankingminority 
                  + partyleader + factor(year), data = obs_data %>% filter(capital == 0)))

summary(mil<-lm(incvote ~ log_cong_direct_spend*factor(gender) + abs(nokken_poole_dim1) +
                             po1 + spendgap + fr + in_party + midterm + approve + 
                             + rdi + incpres + incvotep + memberinhouseparty + cmte_approp + cmte_ways + chair + rankingminority 
                + partyleader + factor(year), data = obs_data %>% filter(capital == 0)))

## Table A2
summary(edu<-lm(incvote ~ I(log(money_edu+1))*factor(gender) + abs(nokken_poole_dim1) +
                  po1 + spendgap + fr + in_party + incpres + cmte_approp + cmte_ways + chair + rankingminority 
                + partyleader, data = earmarks2022))

summary(hhs<-lm(incvote ~ I(log(money_hhs+1))*factor(gender) + abs(nokken_poole_dim1) +
                  po1 + spendgap + fr + in_party + incpres + cmte_approp + cmte_ways + chair + rankingminority 
                + partyleader, data = earmarks2022))


summary(transp<-lm(incvote ~ I(log(money_transp+1))*factor(gender) + abs(nokken_poole_dim1) +
                     po1 + spendgap + fr + in_party + incpres + cmte_approp + cmte_ways + chair + rankingminority 
                   + partyleader, data = earmarks2022))

## Table A3
summary(edu<-feols(approve ~ I(log(money_edu+1))*factor(gender) + abs(nokken_poole_dim1) +
                     copartisan + cmte_approp + cmte_ways + chair + rankingminority 
                   + partyleader, data = ces, cluster = ~ state^cdid117_post,
                   weights = ces$commonweight))

summary(hhs<-feols(approve ~ I(log(money_hhs+1))*factor(gender) + abs(nokken_poole_dim1) +
                     copartisan + cmte_approp + cmte_ways + chair + rankingminority 
                   + partyleader, data = ces, cluster = ~ state^cdid117_post,
                   weights = ces$commonweight))

summary(transp<-feols(approve ~ I(log(money_transp+1))*factor(gender) + abs(nokken_poole_dim1) +
                        copartisan + cmte_approp + cmte_ways + chair + rankingminority 
                      + partyleader, data = ces, cluster = ~ state^cdid117_post,
                      weights = ces$commonweight))

## Table A4
summary(edu<-lm(incvote ~ edu_awards_amount*factor(gender)*cd_pct_educ_undergrad + abs(nokken_poole_dim1) +
                  po1 + spendgap + fr + in_party + midterm + approve + 
                  + rdi + incpres + incvotep + memberinhouseparty + cmte_approp + cmte_ways + chair + rankingminority 
                + partyleader + factor(year), data = obs_data %>% filter(capital == 0)))

summary(hhs<-lm(incvote ~ hhs_awards_amount*factor(gender)*cd_pct_educ_undergrad + abs(nokken_poole_dim1) +
                  po1 + spendgap + fr + in_party + midterm + approve + 
                  + rdi + incpres + incvotep + memberinhouseparty + cmte_approp + cmte_ways + chair + rankingminority 
                + partyleader + factor(year), data = obs_data %>% filter(capital == 0)))

summary(ag<-lm(incvote ~ ag_awards_amount*factor(gender)*cd_pct_educ_undergrad + abs(nokken_poole_dim1) +
                 po1 + spendgap + fr + in_party + midterm + approve + 
                 + rdi + incpres + incvotep + memberinhouseparty + cmte_approp + cmte_ways + chair + rankingminority 
               + partyleader + factor(year), data = obs_data %>% filter(capital == 0)))

summary(transportation<-lm(incvote ~ transp_awards_amount*factor(gender)*cd_pct_educ_undergrad + abs(nokken_poole_dim1) +
                             po1 + spendgap + fr + in_party + midterm + approve + 
                             + rdi + incpres + incvotep + memberinhouseparty + cmte_approp + cmte_ways + chair + rankingminority 
                           + partyleader + factor(year), data = obs_data %>% filter(capital == 0)))

summary(mil<-lm(incvote ~ log_cong_direct_spend*factor(gender)*cd_pct_educ_undergrad + abs(nokken_poole_dim1) +
                  po1 + spendgap + fr + in_party + midterm + approve + 
                  + rdi + incpres + incvotep + memberinhouseparty + cmte_approp + cmte_ways + chair + rankingminority 
                + partyleader + factor(year), data = obs_data %>% filter(capital == 0)))

